package com.Springdemo.service.Impl;

import com.Springdemo.dao.UserMapper;
import com.Springdemo.enity.User;
import com.Springdemo.enity.UserExample;
import com.Springdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: lool
 * @Date: 2022-06-09 16:26
 * @Description:
 */

@Service("UserService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    public UserMapper getUserMapper() {
        return userMapper;
    }

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }


    @Override
    public void update(User user) {
        //封装一个更新user的service
        UserExample example = new UserExample();
        UserExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(user.getId());
        userMapper.updateByPrimaryKey(user);
//        System.out.println(count);
        System.out.println("userMapper.updateByPrimaryKey is done");

    }
}
